#include "uart0.h"
#include "my_printf.h"
#include "lcd.h"

#define  A  (*((volatile unsigned int *)0x33f00000))
#define  B  (*((volatile unsigned int *)0x33f00004))
#define  C  (*((volatile unsigned int *)0x30001000))

/////////////////////

#include "linux/fs.h"
#include "linux/sched.h"


extern void mem_init(long start, long end);


/*
 * This is set up by the setup-routine at boot-time
 *  lgg : we can set it up by ourself 
 */
#define EXT_MEM_K 16*1024
#define DRIVE_INFO (*(struct drive_info *)0x0)
#define ORIG_ROOT_DEV (*(unsigned short *)0x0)

static long memory_end = 0;
static long buffer_memory_end = 0;
static long main_memory_start = 0;

struct drive_info { char dummy[32]; } drive_info;

void lgg_test();

int c_entry(void)
{
	asm("swi 0x0");
#if 0
	ROOT_DEV = ORIG_ROOT_DEV;

	memory_end = (1<<20) + (EXT_MEM_K<<10);
	memory_end &= 0xfffff000;
	if (memory_end > 16*1024*1024)
		memory_end = 16*1024*1024;
	if (memory_end > 12*1024*1024) 
		buffer_memory_end = 4*1024*1024;
	else if (memory_end > 6*1024*1024)
		buffer_memory_end = 2*1024*1024;
	else
		buffer_memory_end = 1*1024*1024;
	main_memory_start = buffer_memory_end;
	// memory_end = 16*1024*1024;     = 16MB
	// main_memory_start = buffer_memory_end; = 4*1024*1024; = 4MB

//#ifdef RAMDISK
#if 0
	main_memory_start += rd_init(main_memory_start, RAMDISK*1024);
#endif

	// main_memory_start : 4MB  memory_end : 16MB
	mem_init(main_memory_start,memory_end);
	//trap_init(); do it in the start.s
#endif
	lgg_test();
	return 0;
}

void lgg_test()
{
	uart0_init();
		
	// step1: uart in out
	my_printf("%x ",A);
	my_printf("%x ",'a');
	my_printf("%x ",'b');
	//uart0_test();
	//step2:  show lcd screen
	rt_hw_lcd_init();
	rt_hw_lcd_test();
	uart0_test();
}

